using System.Collections.Generic;
using UnityEngine;

namespace ClassicBehaviorTree
{
    public class Container : Node
    {
        protected List<Node> _subNodes = new List<Node>();
        protected int _initializeCounter = 0;
        protected int _successCounter = 0;
        public void SetKey(string key)
        {
            _key = key;
        }
        /// <summary>
        /// add node to the list and set the key for subNode
        /// </summary>
        /// <param name="subNode"></param>
        public void AddSubNodes(Node subNode)
        {
            _subNodes.Add(subNode);
            subNode._key = _key + "." + _initializeCounter;
            _initializeCounter++;
        }
        public override void Initialize(MonoBehaviour behaviorTree)
        {
            base.Initialize(behaviorTree);
            _successCounter = 0;
            foreach (Node item in _subNodes)
            {
                item.Initialize(_behaviorTree);
            }
        }
        public override void Reset()
        {
            foreach (Node item in _subNodes)
            {
                item.Reset();
            }
            base.Reset();
        }
    }
}
